import { defHttp } from '/@/utils/http/axios';
import { ErrorMessageMode } from '/#/axios';
enum Api {
  GetLabelList = '/company/label',
  DelLabel = '/company/label',
  GetLabelListByHistory = '/company/label/history',
  AddLabel = '/company/label',
}

// 获取标签列表
export function getLabelList(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.get(
    { url: Api.GetLabelList, params },
    {
      errorMessageMode: mode,
    },
  );
}

// 获取历史标签列表
export function getLabelHistoryList(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.get(
    { url: Api.GetLabelListByHistory, params },
    {
      errorMessageMode: mode,
    },
  );
}

// 移除标签
export async function removeLabel(id: string, mode: ErrorMessageMode = 'message') {
  return defHttp.put(
    {
      url: Api.DelLabel + `/${id}/remove`,
    },
    {
      errorMessageMode: mode,
    },
  );
}

// 删除标签
export async function delLabel(id: string, mode: ErrorMessageMode = 'message') {
  return defHttp.delete<boolean>(
    {
      url: Api.DelLabel + `/${id}`,
    },
    {
      errorMessageMode: mode,
    },
  );
}

// 新增标签
export function addLabel(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.post(
    { url: Api.AddLabel, params },
    {
      errorMessageMode: mode,
    },
  );
}
